﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
#if LIVE
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.GamerServices;
#endif
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
#if WINDOWS_PHONE
using Microsoft.Xna.Framework.Input.Touch;
#endif
#if WINDOWS

using Microsoft.Xna.Framework.Storage;
#endif
using Microsoft.Xna.Framework.Media;
using Neat;
using Neat.MenuSystem;
using Neat.EasyMenus;
using Neat.GUI;
using Neat.Mathematics;
using Neat.Graphics;

namespace RiverRaidX
{
    public class CreditsScreen : Screen
    {
        public CreditsScreen(NeatGame Game)
            : base(Game)
        {
        }

        Effect fsfx;
        public override void LoadContent()
        {
            game.LoadTexture(@"Sprites\Credits");
            base.LoadContent();
        }
        
        public override void HandleInput(GameTime gameTime)
        {
            if (game.IsTapped(Keys.Space) || game.IsTapped(Keys.Enter) || game.IsTapped(Keys.Escape) || game.IsMouseClicked())
                finish();
#if KINECT
            foreach (var item in game.Touch.TrackPoints)
            {
                if (item.Hold) finish();
            }
#endif
            base.HandleInput(gameTime);
        }

        void finish()
        {
            game.ActivateScreen("mainmenu");
        }

        public override void Activate()
        {
            base.Activate();
            fsfx = game.GetEffect("fullscreen");
            fsfx.CurrentTechnique = fsfx.Techniques["Noise"];
        }

        public override void Deactivate(string nextScreen)
        {
            base.Deactivate(nextScreen);
            fsfx.CurrentTechnique = fsfx.Techniques["Technique1"];
        }

        public override void Render(GameTime gameTime)
        {
            game.UseEffect(fsfx);
            fsfx.Parameters["noise"].SetValue((float)game.RandomGenerator.NextDouble());
            game.SpriteBatch.Draw(game.GetTexture("credits"),
                new Rectangle(0, 0, game.GameWidth, game.GameHeight),
                Color.White);
            game.RestartBatch();
            base.Render(gameTime);
        }
    }
}
